<template>
    <div class="page-newhandwelfare">
      <img src="../../public/imgs/newhandwelfare/top_banner.png" alt="">
      <section class="setp_1">
        <img src="../../public/imgs/newhandwelfare/step_1_right.png" alt="" class="right">
         <div class="title">
           福利1 <span>新手标也可用券</span>
         </div>
         <div class="content">
             <div class="item">
                <div class="name"><span>15%</span> 新手标</div>
                <div class="ohter_name">新手专享</div>
             </div>
              <div>
                <img src="../../public/imgs/newhandwelfare/add.png" alt=""  class="add">
              </div>
              <div class="item">
                <div class="name"><span>2%</span> 加息券</div>
                <div class="ohter_name">绑卡即送，全场通用</div>
              </div>
         </div>
         <div class="radius_btn">
           最终预期年化 <span>17%</span>
         </div>
      </section>

  <section class="step_2">
   <div class="title">
           福利2 <span>双重 <img src="../../public/imgs/newhandwelfare/hot.png" alt=""> 火爆新手标</span>
         </div>

     <div class="item_content">
        <!-- <div class="item">
          <div class="progress">15.00%</div>
          <div class="year">预期年化</div>
          <div class="remaining">
           <div class="text" v-show="islogin"> <div v-show="surplusInvestmentAmount1>0">您剩余可投{{surplusInvestmentAmount1.toFixed(2)}}万元</div><div v-show="surplusInvestmentAmount1<=0">您剩余可投0.00万元</div></div>
             <div class="text small"  v-show="!islogin"> <span>最大可投{{maxInvestAmount1.toFixed(2)}}万元/人</span></div>
            <div class="bg"  v-show="islogin" :style="{'width':getWidth(surplusInvestmentAmount1,maxInvestAmount1)+'%','borderTopRightRadius':getradius(surplusInvestmentAmount1,maxInvestAmount1),'borderBottomRightRadius':getradius(surplusInvestmentAmount1,maxInvestAmount1)}"  ></div>
          </div>
          <div class="day">15<span>天左右产品</span></div>
        </div>
        <div class="item">
          <div class="progress">12.00%</div>
          <div class="year">预期年化</div>
          <div class="remaining">
           <div class="text" v-show="islogin"> <div v-show="surplusInvestmentAmount2>0">您剩余可投{{surplusInvestmentAmount2.toFixed(2)}}万元</div><div v-show="surplusInvestmentAmount2<=0">您剩余可投0.00万元</div></div>
             <div class="text small"  v-show="!islogin"> <span>最大可投{{maxInvestAmount2.toFixed(2)}}万元/人</span></div>
            <div class="bg"  v-show="islogin" :style="{'width':getWidth(surplusInvestmentAmount2,maxInvestAmount2)+'%','borderTopRightRadius':getradius(surplusInvestmentAmount2,maxInvestAmount2),'borderBottomRightRadius':getradius(surplusInvestmentAmount2,maxInvestAmount2)}" ></div>
          </div>
          <div class="day">30<span>天左右产品</span></div>
        </div>
        <div class="item">
          <div class="progress">13.00%</div>
          <div class="year">预期年化</div>
          <div class="remaining">
          <div class="text" v-show="islogin"> <div v-show="surplusInvestmentAmount3>0">您剩余可投{{surplusInvestmentAmount3.toFixed(2)}}万元</div><div v-show="surplusInvestmentAmount3<=0">您剩余可投0.00万元</div></div>
             <div class="text small"  v-show="!islogin"><span> 最大可投{{maxInvestAmount3.toFixed(2)}}万元/人</span></div>
            <div class="bg"  v-show="islogin" :style="{'width':getWidth(surplusInvestmentAmount3,maxInvestAmount3)+'%','borderTopRightRadius':getradius(surplusInvestmentAmount3,maxInvestAmount3),'borderBottomRightRadius':getradius(surplusInvestmentAmount3,maxInvestAmount3)}" ></div>
          </div>
          <div class="day">60<span>天左右产品</span></div>
        </div>
        <div class="item">
          <div class="progress">14.00%</div>
          <div class="year">预期年化</div>
          <div class="remaining">
            <div class="text" v-show="islogin"> <div v-show="surplusInvestmentAmount4>0">您剩余可投{{surplusInvestmentAmount4.toFixed(2)}}万元</div><div v-show="surplusInvestmentAmount4<=0">您剩余可投0.00万元</div></div>
            <div class="text small"  v-show="!islogin"> <span>最大可投{{maxInvestAmount4.toFixed(2)}}万元/人</span></div>
            <div class="bg"  v-show="islogin" :style="{'width':getWidth(surplusInvestmentAmount4,maxInvestAmount4)+'%','borderTopRightRadius':getradius(surplusInvestmentAmount4,maxInvestAmount4),'borderBottomRightRadius':getradius(surplusInvestmentAmount4,maxInvestAmount4)}" ></div>
          </div>
          <div class="day">90<span>天左右产品</span></div>
        </div> -->
        <!-- <img src="../../public/imgs/newhandwelfare/step2_main.png"> -->
        <p>每种期限新手标均可投资1次，老用户若有某期限新手 标未投资，则该期限新手标可同享投资机会</p>
        <div class="new_list" @click="jumpToProductList(item.productId)" v-for="(item,index,) in list" :class="{'no':index==0}">
          <div class="left">
            <div class="a_1">{{item.yearIncome}}%</div>
             <div class="a_2">预期年化</div>
          </div>
          <div class="right">
             <div class="a_3"><span class="red">{{item.interestLimitDes}}</span>{{item.interestLimitType}}<span class="line">|</span><span class="money">{{item.partInvestAmount}}</span>元起购<span class="jump">></span></div>
               <div class="a_4" v-if="item.sell!==-1">
                  <span class="text_a" v-show="item.sell!==1"> 剩余{{item.surplusInvestAmount/10000}}万元</span>
                  <span class="text_a" v-show="item.sell==1">已完成</span>
                  <mt-progress :value="item.progress" :bar-height="18" :class="{'active':item.progress>=96}"></mt-progress>
                 </div>
                  <div class="a_4" v-if="item.sell==-1">
                <div class="icon_countDown">
                  <img src="../../public/imgs/newhandwelfare/icon_countDown.png" alt="">
                  <count-down :item="item"></count-down>
                   后开始
              </div> 
                 </div>
          </div>
        </div>
 
    </div>
  </section>

   <section class="step_3">
    <!-- <div class="title">
           福利3 <span>2088元抵现礼包</span>
    </div>
      <div >
        <img src="../../public/imgs/newhandwelfare/step_3_main.png" alt="" class="step_3_main">
     </div> -->
     <div class="option">
      <div>不知福利如何领取？</div>
      <div @click="jumpins()" class="jump">点击查看 <span>新手操作指南</span></div>
     </div>
     <div class="rule">
     *活动仅成年人可参与，相关理财产品不保证本金和收益，投资有
      风险，理财需谨慎
     </div>
   </section>
   <div>
      <div class="bottom_btn" v-show="islogin==false" @click="jumplogin()">
            立即注册
         </div>
         <div  class="bottom_btn"  v-show="islogin==true">
             <span v-show="bindCard==false" @click="jumpbindCard()">
                绑卡即送2%加息券
             </span>
             <span v-show="bindCard==true"  @click="jumpInvist()">
                 立即投资
             </span>
         </div>
   </div>
    </div>
</template>

<script>
import { Toast,Progress } from "mint-ui";
import countDown from "components/countdown.vue";
export default {
  props: [],
  data() {
    return {
      sessionid: "",
      islogin: false,
      bindCard: false,
      noviceProduct: false,
      surplusInvestmentAmount1: 5,
      surplusInvestmentAmount2: 5,
      surplusInvestmentAmount3: 5,
      surplusInvestmentAmount4: 5,
      maxInvestAmount1: 5,
      maxInvestAmount2: 5,
      maxInvestAmount3: 5,
      maxInvestAmount4: 5,
      appversion: 170,
      list:[],
    };
  },
   components: {
    countDown
  },
  created() {
    this.getList()

    if (this.Uitis.isClient) {
      var UserInfo = APP.getInfo();
      UserInfo.then(res => {
        if (res.versionCode) {
          this.appversion = res.versionCode;
        }
        if (res.uId !== "") {
          this.sessionid = res.sessionid;
          this.getState();//获取绑卡状态
          // this.getTaskCollegeNoviceQuota();
          this.islogin = true;
        } else {
          this.islogin = false;
          // this.getTaskCollegeNoviceQuota();
        }
      });
    } else {
      this.sessionid = localStorage.getItem("sessionid");
      if (this.sessionid !== null && this.sessionid !== "") {
        this.getState();//获取绑卡状态
        // this.getTaskCollegeNoviceQuota();
        this.islogin = true;
      } else {
        this.islogin = false;
        // this.getTaskCollegeNoviceQuota();
      }
    }
  },
  mounted() {},
  methods: {
    getList(){
      this.$http.get(this.Interface.getmz_app_novice_product_list).then(res=>{
       if(res.data.success==true){
         this.list=res.data.data.list;
       }
      })
    },
    getradius(Invest, maxInves) {
      if (Invest < 0 || Invest == 0) {
        return "0.2rem";
      } else {
        return "0rem";
      }
    },
    getWidth(Invest, maxInvest) {
      if (Invest < 0) {
        return 100;
      } else {
        if (Invest == maxInvest) {
          return 0;
        } else {
          if (1 - Invest / maxInvest < 0.05) {
            return 5;
          } else {
            return 100 - Invest / maxInvest * 100;
          }
        }
      }
    },
    getTaskCollegeNoviceQuota() {
      this.$http
        .post(this.Interface.taskCollegeNoviceQuota, {
          sessionid: this.sessionid
        })
        .then(res => {
          if (res.data.success) {
            if (res.data.data.surplusInvestmentAmount1 == null) {
              this.surplusInvestmentAmount1 = 0;
              this.surplusInvestmentAmount2 = 0;
              this.surplusInvestmentAmount3 = 0;
              this.surplusInvestmentAmount4 = 0;
            } else {
              this.surplusInvestmentAmount1 =
                res.data.data.surplusInvestmentAmount1 / 10000;
              this.surplusInvestmentAmount2 =
                res.data.data.surplusInvestmentAmount2 / 10000;
              this.surplusInvestmentAmount3 =
                res.data.data.surplusInvestmentAmount3 / 10000;
              this.surplusInvestmentAmount4 =
                res.data.data.surplusInvestmentAmount4 / 10000;
            }
            this.maxInvestAmount1 = res.data.data.maxInvestAmount1 / 10000;
            this.maxInvestAmount2 = res.data.data.maxInvestAmount2 / 10000;
            this.maxInvestAmount3 = res.data.data.maxInvestAmount3 / 10000;
            this.maxInvestAmount4 = res.data.data.maxInvestAmount4 / 10000;
          } else {
            Toast({
              message: res.data.message || res.data.data.error_msg,
              position: "center",
              duration: 2000
            });
          }
        });
    },
    getState() {
      this.$http
        .get(this.Interface.getTaskCollegr, {
          params: { sessionid: this.sessionid }
        })
        .then(res => {
          if (
            res.data.success == false &&
            res.data.data.error_code == "700002"
          ) {
            //已经领取状态
            this.bindCard = true;
            this.noviceProduct = true;
          } else if (res.data.success) {
            this.bindCard = res.data.data.bindCard;
            this.noviceProduct = res.data.data.coupons;
          }
        });
    },
    jumplogin() {
      if (this.Uitis.isClient) {
        if (this.Uitis.isAndroid) {
          if (this.appversion <= 170) {
            this.Uitis.JumpNavite("jumpToRegister");
          } else {
            this.Uitis.JumpNavite("jumpInsideToRegister");
          }
        } else {
          if (this.appversion <= 170) {
            this.Uitis.JumpNavite("jumpToLogin");
          } else {
            this.Uitis.JumpNavite("jumpInsideToRegister");
          }
        }
      } else {
        sessionStorage.setItem("newhandwelfare", 1);
        window.location.href = `${this.Interface.wabapp}register`;
      }
    },
    jumpbindCard() {
      if (this.Uitis.isClient) {
        this.Uitis.JumpNavite("jumpToAddBankCard");
      } else {
        window.location.href = `${this.Interface.wabapp}bindcard`;
      }
    },
    jumpToProductList(id){
       this.Uitis.jumpToProduct(id)
    },
    jumpInvist() {
      if (this.Uitis.isClient) {
        this.Uitis.JumpNavite("jumpToProductList");
      } else {
        window.location.href = `${this.Interface.wabapp}productlist`;
      }
    },
    dowonload() {
      window.location.href =
        "http://a.app.qq.com/o/simple.jsp?pkgname=com.preference.mz.android";
    },
    jumpins() {
      let urlObj = {
        link: `${this.Interface.getH5}newhandwelfareGuide.html`
      };
      this.Uitis.Jump(urlObj);
    }
  }
};
</script>
<style lang="less">
.page-newhandwelfare {
  background: #fff;
  .setp_1 {
    width: 690px;
    position: relative;
    margin: 0 auto;
    margin-top: -282px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0px 8px 8px #ebe2f3;
    box-sizing: border-box;
    padding: 45px 35px 45px 35px;

    .title {
      font-size: 44px;
      font-weight: 600;
      span {
        font-size: 30px;
        color: #333;
        font-weight: initial;
        margin-left: 20px;
        font-family: "苹方";
      }
    }
    .content {
      margin-top: 50px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .add {
        width: 18px;
      }
      .item {
        text-align: center;
        width: 280px;
        border-radius: 5px;
        box-shadow: 0px 10px 20px 0px rgba(126, 64, 175, 0.2);
        border: 1px solid #fcfbfd;
        box-sizing: border-box;
        padding: 30px 15px;
        .name {
          font-size: 34px;
          font-weight: 600;
          span {
            color: #ff4444;
            font-family: "DinPro";
            font-weight: initial;
            font-size: 38px;
          }
        }
        .ohter_name {
          font-size: 24px;
          color: #333;
          margin-top: 30px;
          font-family: "苹方";
        }
      }
    }

    .left {
      position: absolute;
      top: -53px;
      left: -18px;
      width: 66px;
    }
    .right {
      position: absolute;
      top: -2px;
      right: -5px;
      width: 86px;
    }

    .radius_btn {
      width: 100%;
      text-align: center;
      font-weight: 600;
      color: #ff4444;
      background: #ffe8ec;
      border-radius: 50px;
      padding: 30px 0px;
      font-size: 34px;
      margin-top: 50px;
      span {
        font-size: 40px;
      }
    }
  }
  .step_2 {
    position: relative;
    margin-top: -40px;

    padding: 55px 35px;
    .title {
      font-size: 44px;
      font-weight: 600;
      margin-top: 50px;
      margin-left: 30px;
      span {
        font-size: 30px;
        color: #333;
        font-weight: initial;
        margin-left: 20px;
      }
      img {
        width: 38px;
        height: 37px;
      }
    }
    .item_content {
      // background: url(../../public/imgs/newhandwelfare/Part2_BG.png) no-repeat
      //   top center;
      // background-size: contain;
      // position: relative;
      // padding: 0 30px;
      background: linear-gradient(#ff4444,#ffe3ba);
      margin-top: 50px;
      margin-bottom: 85px;
      height: 502px;
      padding: 34px;
      box-sizing: border-box;
      border-radius: 6px;
      // padding-top: 30px;
      &>p {
        font-size: 26px;
        color: #fff;
        margin-bottom: 40px;
        line-height: 45px;
      }
      .f-l-list {
        height: 200px;
        display: flex;  
        align-items: center;
        background: #FFF;
        border-radius: 6px;
        margin-top: 20px;
        box-shadow: 0 10px 20px rgba(175,64,64,0.2);
        ul {
          display: flex;
          width: 100%;
          padding: 0 50px 0 30px;
          box-sizing: border-box;
          justify-content: space-between;
          text-align: center;
          align-items: flex-end;
          li {
            h1 {
              font-size: 30px;
              color: #333;
            }
            p {
              margin-top: 25px;
              font-size: 24px;
              color: #999;
            }
            &:first-child {
              h1 {
                font-size: 54px;
                color: #ff4444;
              }
            }
          }
        }
      }
      .item {
        width: 300px;
        border-radius: 5px;
        box-shadow: 0px 10px 20px 0px rgba(126, 64, 175, 0.2);
        border: 1px solid #fcfbfd;
        box-sizing: border-box;
        background: #fff;
        margin-bottom: 30px;
        padding: 30px;
        .progress {
          font-family: "DinPro";
          font-size: 54px;
          color: #ec3737;
        }
        .year {
          font-size: 24px;
          color: #333333;
          margin-top: 25px;
        }
        .remaining {
          border: 1px solid #ec3737;
          border-radius: 20px;
          text-align: center;
          color: #ec3737;
          background: #fff;
          position: relative;
          height: 30px;
          margin-top: 25px;
          box-sizing: border-box;
          .text {
            position: absolute;
            background: transparent;
            width: 100%;
            text-align: center;
            border-radius: 20px;
            font-size: 20px;
            z-index: 2;
            display: flex;
            align-items: center;
            height: 100%;
            text-align: center;
            span {
              width: 100%;
              height: 100%;
              line-height: 30px;
            }
            div {
              position: relative;
              width: 100% !important;
              text-align: center;
              line-height: normal;
              display: table-cell;
              vertical-align: middle;
            }
          }

          .bg {
            border-top-left-radius: 15px;
            border-bottom-left-radius: 15px;
            background: #fce1e1;
            height: 100%;
          }
        }
        .day {
          margin-top: 25px;
          font-size: 30px;
          color: #333;
          span {
            color: #999;
            margin-left: 5px;
          }
        }
      }
      .new_list{
        background: #fff;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        box-sizing: border-box;
        padding: 45px;
          box-shadow: 0px 10px 20px #f1e2e1;
          margin-bottom: 25px;
            font-family: "DinPro";
        .left,.right{height: 120px; display: flex;flex-direction: column;justify-content: space-between;}
        .a_1{font-size: 54px;color: #ff4444;font-family: "DinPro"}
        .a_2{font-size: 24px;color: #999;margin-top: 40px;}
        .a_3{font-size: 30px;color: #999;padding-top: 15px;  .red{color: #ff5555;padding-right:10px; }
          .line{padding: 0px 20px;}
          .money{color: #666;padding-right: 5px;}
          .jump{padding-left: 10px;}
        }
        .a_4{
          margin-top: 30px;
          position: relative;
          .icon_countDown{
            color: #5261f7;
            font-size: 30px;
            img{width: 28px;margin-right: 10px;};
            display: flex;
            align-items: center;
          }
          .text_a{
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate3d(-50%,-50%,0);
            font-size: 26px;
            color: #cca166;
            z-index: 9;
            width: 100%;
            text-align: center;
          }
          .mt-progress{height: 0px;;}
          .mt-progress-runway{border-radius: 20px;background: #fff;border:0.02rem solid #e8d1b0;overflow: hidden;}
          .mt-progress-progress{border-top-left-radius: 20px; border-bottom-left-radius: 20px; background: #faf0e3;height: 32px !important;;left: 2px}
          .active{ 
            .mt-progress-progress{
              border-radius: 20px;
            }
          }
        }
      }
      .no{
        box-shadow: 0 0 0 0;
      }
    }
  }
  .step_3 {
    text-align: center;
    .title {
      text-align: left;
      font-size: 44px;
      font-weight: 600;
      margin-left: 70px;
      margin-top: 10px;
      span {
        font-size: 30px;
        color: #ec3737;
        margin-left: 20px;
        font-weight: initial;
      }
    }
    .option {
      border-radius: 6px;
  background-color: rgb(255, 255, 255);
  box-shadow:  0px 10px 40px rgba(175, 64, 64, 0.2);
  margin: 0 auto;
  margin-top: 0px;
    width: 693px;
    font-weight: bold;
    font-size: 28px;
    color: #333;
    line-height: 45px;
    padding: 50px 0px;
      .jump {
        span{color: #ff4444}
      }
    }
    .rule {
      margin-left: 65px;
      text-align: left;
      font-size: 26px;
      color: #7f557d;
      line-height: 50px;
      margin-top: 50px;
      padding-bottom: 40px;
    }
    .step_3_main {
      width: 628px;
      height: 240px;
      margin: 0 auto;
      margin-top: 50px;
    }
  }
  .bottom_btn {
    width: 100%;
    background: url(../../public/imgs/newhandwelfare/bottom_btn.png) no-repeat;
    height: 115px;
    background-size: cover;
    font-size: 44px;
    color: #fff;
    text-align: center;
    line-height: 110px;
    margin-top: 30px;
  }
}
</style>
